document.addEventListener('DOMContentLoaded', function() {

    const navbar = document.querySelector('.navbar');
    window.addEventListener('scroll', function() {
        if (window.scrollY > 50) {
            navbar.classList.add('scrolled');
        } else {
            navbar.classList.remove('scrolled');
        }
    });

    const backToTopButton = document.querySelector('.back-to-top');
    window.addEventListener('scroll', function() {
        if (window.scrollY > 300) {
            backToTopButton.classList.add('active');
        } else {
            backToTopButton.classList.remove('active');
        }
    });
    
    backToTopButton.addEventListener('click', function(e) {
        e.preventDefault();
        window.scrollTo({
            top: 0,
            behavior: 'smooth'
        });
    });

    const animateOnScroll = function() {
        const elements = document.querySelectorAll('.animate-on-scroll');
        elements.forEach(element => {
            const elementPosition = element.getBoundingClientRect().top;
            const windowHeight = window.innerHeight;
            
            if (elementPosition < windowHeight - 100) {
                element.classList.add('fade-in-up');
            }
        });
    };
    
    window.addEventListener('scroll', animateOnScroll);
    animateOnScroll(); // 初始检查

    const partnerLogos = document.querySelectorAll('.partner-card');
    partnerLogos.forEach(logo => {
        logo.addEventListener('mouseenter', () => {
            logo.querySelector('img').style.transform = 'scale(1.1)';
        });
        logo.addEventListener('mouseleave', () => {
            logo.querySelector('img').style.transform = 'scale(1)';
        });
    });

    console.log('%c欢迎访问闲转二手交易平台', 'color: #6c63ff; font-size: 16px; font-weight: bold;');
    console.log('%c关于我们页面已加载', 'color: #28a745; font-size: 14px;');
});